#include "heroninja.h"
#include "config.h"
HeroNinja::HeroNinja()
{
    m_Ninja.load(HERO_PATH);

    m_X =(GAME_WIDTH - m_Ninja.width())*0.5;
    m_Y =GAME_HEIGHT - m_Ninja.height();

    m_Rect.setWidth(m_Ninja.width());
    m_Rect.setHeight(m_Ninja.height());
    m_Rect.moveTo(m_X,m_Y);
}

void HeroNinja::shoot()
{
    m_recorder++;

    if(m_recorder < BULLET_INTERVAL)
    {
        return;
    }
    m_recorder = 0;

    for(int i=0;i<BULLET_NUM;i++)
    {
        if(m_bullets[i].m_Free)
        {
            m_bullets[i].m_Free=false;
            m_bullets[i].m_X=m_X;
            m_bullets[i].m_Y=m_Y;
            break;
        }
    }

}

void HeroNinja::setPosition(int x, int y)
{
    m_X = x;
    m_Y = y;
    m_Rect.moveTo(m_X,m_Y);
}
